#### return max
proc gen_max {alist} {
	set alist_length [llength $alist]
	set max [lindex $alist 0]
	for {set a 0} {$a < $alist_length} {incr a} {
		if { [lindex $alist $a] > $max } {
			set max [lindex $alist $a]
		}
	}
	return $max
}

proc gen_min {alist} {
	set alist_length [llength $alist]
	set min [lindex $alist 0]
	for {set a 0} {$a < $alist_length} {incr a} {
		if { [lindex $alist $a] < $min } {
			set min [lindex $alist $a]
		}
	}
	return $min
}

proc gen_clean_data_from_python {string_python} {
	return [string map {"\[" "\{" "\]" "\}" ", " " "} $string_python]
	
}

proc gen_run_python {python_path} {
	return [exec /apps/mentor/aoi_cal_2018.4_17.10/bin/python3 $python_path]
}

proc gen_file_to_list { file_path } {
	set f [open $file_path r]
	set re_list [list ]
	while { [gets $f line] != -1 } {
		lappend re_list [string trim $line]
		puts "append $line"
	}
	close $f
	return $re_list	
}

proc pr_round_4 {number} {
	return [format "%.4f" $number]
}

proc pr_auto_edit_wire {layer net width pt_list} {
	# M11 VDD 10.5 {{11.2 23.3} {22.3 66.3}}
	uiSetTool select
	uiSetTool addWire
	setEditMode \
		-allow_45_degree true \
		-layer $layer \
		-layer_horizontal $layer \
		-layer_vertical $layer \
		-nets $net \
		-width_horizontal $width \
		-width_vertical $width \
		-status fixed
	set a 1
	set len_pt_list [llength $pt_list]
	puts $len_pt_list
	foreach i $pt_list {
		puts $a
		if { $a == $len_pt_list } {
			editCommitRoute $i
		} else {
			editAddRoute $i
		}
		incr a
	}
	uiSetTool select
}

proc pr_int_to_str {a} {
	if {$a < 10} {
		return 0000$a
	} elseif { $a < 100 } {
		return 000$a
	} elseif { $a < 1000 } {
		return 00$a
	} elseif { $a < 10000 } {
		return 0$a
	}
}